package com.dyb.demo.strategy;

/**
 * 实现B
 * @author dyb
 * @date 2021/1/26
 */
public class B extends AbstractStrategyRouter<String, String> implements StrategyHandler<String, String> {

    @Override
    protected StrategyMapper<String, String> registerStrategyMapper() {
        return p -> new C();
    }

    @Override
    public String apply(String param) {
        System.out.println(String.format("[B apply] %s", param));
        // next C
        StrategyMapper<String, String> strategyMapper = this.registerStrategyMapper();
        StrategyHandler<String, String> strategyHandler = strategyMapper.get("C");
        return strategyHandler.apply("B Handle C");
    }
}
